package com.example.demo.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeoutException;

/**
 * @Author：zhoutaoming
 * @name：RabbitMqUtil
 * @Date：2024/5/8 15:29
 * @Version 1.0
 */
public class RabbitMqUtil {

            private static final String RABBITMQ_HOST = "localhost";
            private static final int RABBITMQ_PORT = 5672;
            private static final String RABBITMQ_USERNAME = "guest";
            private static final String RABBITMQ_PASSWORD = "guest";

            public static void main(String[] args) {
//                ConnectionFactory factory = new ConnectionFactory();
//                factory.setHost(RABBITMQ_HOST);
//                factory.setPort(RABBITMQ_PORT);
//                factory.setUsername(RABBITMQ_USERNAME);
//                factory.setPassword(RABBITMQ_PASSWORD);
//
//                try (Connection connection = factory.newConnection();
//                     Channel channel = connection.createChannel()) {
//
//                    // 获取所有的 Exchange 列表
//                    Map<String, Object> exchanges = channel.exchangeDeclare();
//                    for (String exchangeName : exchanges.keySet()) {
//                        // 删除 Exchange
//                        channel.exchangeDelete(exchangeName);
//                        System.out.println("Deleted Exchange: " + exchangeName);
//                    }
//
//                    System.out.println("All exchanges deleted successfully.");
//                } catch (IOException exception) {
//                    exception.printStackTrace();
//                } catch (TimeoutException e) {
//                    throw new RuntimeException(e);
//                }
            }
}
